package com.lyl.yygh.service.hosp.controller;

import com.lyl.yygh.common.service_util.result.Result;
import com.lyl.yygh.model.hosp.HospitalSet;
import com.lyl.yygh.model.vo.HospitalSetQueryVo;
import com.lyl.yygh.service.hosp.service.HospitalSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author luoyalong
 */
@Api(tags = "医院设置管理")
@RestController
@RequestMapping("/admin/hosp/hospitalSet")
public class HospController {
    @Resource
    private HospitalSetService hospitalSetService;

    @ApiOperation(value = "获取所有医院的设置")
    @GetMapping("findAll")
    public Result findAll(){
        List<HospitalSet> list = hospitalSetService.list();
        return Result.ok(list);
    }

    @ApiOperation(value = "逻辑删除医院设置")
    @DeleteMapping("{id:\\d+}")
    public Result removeHospSet(@PathVariable long id){
        boolean flag = hospitalSetService.removeById(id);
        return flag ? Result.ok() : Result.fail();
    }

    @ApiOperation(value = "条件查询带分页")
    @PostMapping("findPageHospSet/{current:\\d+}/{limit:\\d+}")
    public Result findPageHospSet(@PathVariable long current,
                                  @PathVariable long limit,
                                  @RequestBody(required = false) HospitalSetQueryVo queryVo){
        System.out.println("current = " + current + ", limit = " + limit + ", queryVo = " + queryVo);
        return hospitalSetService.findPageHospSet(current,limit,queryVo);
    }

    @ApiOperation(value = "添加医院设置")
    @PostMapping("saveHospSet")
    public Result saveHospSet(@RequestBody HospitalSet set){
        System.out.println("set = " + set);
        //设置状态， 1使用，2不能使用
        return hospitalSetService.saveHospSet(set);
    }




}
